package o;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import o.dky.h;
import o.dky.i;

public class djl extends AlertDialog {
    private ProgressBar ˊ;
    private TextView ˋ;
    private String ˎ = "";
    @SuppressLint({"HandlerLeak"})
    private Handler ˏ = new Handler(this) {
        final /* synthetic */ djl ˋ;

        {
            this.ˋ = r1;
        }

        public void handleMessage(Message message) {
            if (message.what == 1 && !this.ˋ.isShowing() && !ActivityUtil.isAcitivtyNotValid(this.ˋ.ॱ)) {
                try {
                    this.ˋ.show();
                    ayw.ˊ(this.ˋ.getWindow());
                } catch (Exception e) {
                    Logger.e("LoadingDialog", "handleMessage, ex = " + e.toString());
                }
            }
        }
    };
    private Context ॱ;

    public djl(Context context) {
        super(context);
        this.ॱ = context;
        ayw.ˊ(getWindow());
        View inflate = LayoutInflater.from(getContext()).inflate(i.ˉ, null);
        setView(inflate);
        this.ˊ = (ProgressBar) inflate.findViewById(h.ꞌ);
        this.ˋ = (TextView) inflate.findViewById(h.ʻᐝ);
        this.ˋ.setText(this.ˎ);
    }

    public void ˋ(String str) {
        if (!dof.ॱ(str)) {
            this.ˎ = str;
            this.ˋ.setText(this.ˎ);
        }
    }

    public void dismiss() {
        if (this.ॱ != null && !((Activity) this.ॱ).isFinishing()) {
            super.dismiss();
        }
    }

    public void show() {
        if (this.ॱ == null || ((Activity) this.ॱ).isFinishing()) {
            Object obj;
            String str = "LoadingDialog";
            StringBuilder append = new StringBuilder().append("show dlg error, context = ").append(this.ॱ).append(", mContext.isFinishing is ");
            if (this.ॱ == null) {
                obj = "context == null";
            } else {
                obj = Boolean.valueOf(((Activity) this.ॱ).isFinishing());
            }
            Logger.e(str, append.append(obj).toString());
            return;
        }
        try {
            super.show();
            ayw.ˊ(getWindow());
        } catch (Throwable e) {
            Logger.ˋ("LoadingDialog", "show dlg error, e: ", e);
        }
        if (this.ˊ != null) {
            this.ˊ.setVisibility(0);
        }
    }

    public void ˎ(long j) {
        this.ˏ.sendMessageDelayed(this.ˏ.obtainMessage(1), j);
    }

    public void ˏ() {
        this.ˏ.removeMessages(1);
    }
}
